class HomeResponse {
  final int code;
  final String msg;
  final Data data;

  HomeResponse({required this.code, required this.msg, required this.data});

  factory HomeResponse.fromJson(Map<String, dynamic> json) {
    return HomeResponse(
      code: json['code'],
      msg: json['msg'],
      data: Data.fromJson(json['data']),
    );
  }
  Map<String, dynamic> toJson() {
    return {
      'code': code,
      'msg': msg,
      'data': data.toJson(),
    };
  }
}

class Data {
  List<AppCategory> apps;
  Data({required this.apps});

  factory Data.fromJson(Map<String, dynamic> json) {
    return Data(
      apps: (json['apps'] as List<dynamic>).map((category)=>AppCategory.fromJson(category as Map<String, dynamic>)).toList(),
    );
  }
  Map<String, dynamic> toJson() {
    return {
      'apps': apps.map((category) => category.toJson()).toList(),
    };
  }

  static Data init() {
    return Data(apps: []);
  }
}


class AppCategory {
  String title;
  List<AppItem> list;
  AppCategory({required this.title,required this.list});
  factory AppCategory.fromJson(Map<String, dynamic> json) {
    return AppCategory(
      title: json['title'],
      list: (json['list'] as List<dynamic>)
          .map((item) => AppItem.fromJson(item as Map<String, dynamic>))
          .toList(),
    );
  }
  Map<String, dynamic> toJson() {
    return {
      'title': title,
      'list': list.map((item) => item.toJson()).toList(),
    };
  }

  static AppCategory init(){
    return AppCategory(title: "", list: [AppItem.init()]);
  }

}

class AppItem {
  String name;
  String icon;
  int id;

  AppItem({required this.name,required this.icon,required this.id});

  factory AppItem.fromJson(Map<String, dynamic> json) {
    return AppItem(
      name: json['name'],
      icon: json['icon'],
      id: json['id'],
    );
  }
  Map<String, dynamic> toJson() {
    return {
      'name': name,
      'icon': icon,
      'id': id,
    };
  }

  static init() {
    return AppItem(name: "", icon: "", id: 0);
  }
}